package kr.hkit.powerjava.chapter22.work2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;

import kr.hkit.powerjava.chapter22.work2.dao.DepartmentManagerImpl;
import kr.hkit.powerjava.chapter22.work2.dao.StudentManagerImpl;
import kr.hkit.powerjava.chapter22.work2.vo.Department;
import kr.hkit.powerjava.chapter22.work2.vo.Student;

public class TestMain {
	public static void main(String[] args) {
		
		  ArrayList<Department> depList=new ArrayList<>();
		  DepartmentManagerImpl dm =new DepartmentManagerImpl(depList);
		  //추가
		  Department dm1=new Department(1, "히히", 1);
		  dm.addItem(dm1);
		  
		  Department dm2=new Department(2, "하하", 2);
		  dm.addItem(dm2);
		  
		  Department dm3=new Department(3, "헤헤", 4);
		  dm.addItem(dm3);
		  
		  Department dm4=new Department(4, "호호", 3);
		  dm.addItem(dm4);

		  //삭제
//		  dm.delItem(dm2);

		  //검색
		  Department searchItem=new Department(1, "히히");
		  String result = dm.searchItem(searchItem)?"존재":"없음";
		  System.out.println(searchItem.getDeptNo()+":"+searchItem.getDeptName());
		  
		  //수정
		  Department updateItem=new Department (1, "히히",1);
		  dm.updateItem(updateItem);
		  
		  
		  //출력
		  	dm.prnItems();
		  	System.out.println("층");
		  	dm.prnItems(new Comparator<Department>() {

				@Override
				public int compare(Department o1, Department o2) {
					return o2.getFloor()-o1.getFloor();
			}
	  	});
		  	
		  	dm.prnItems();
		  	System.out.println("이름");
		  	dm.prnItems(new Comparator<Department>() {

				@Override
				public int compare(Department o1, Department o2) {
					// TODO Auto-generated method stub
					return o2.getDeptName().hashCode()-o1.getDeptName().hashCode();
				}
		  		
			});
		  	
	}
}
		  

		  

			

		 
/*		ArrayList<Student> stdList = new ArrayList<>();
		StudentManagerImpl sm = new StudentManagerImpl(stdList);
		// 추가
		Student std1 = new Student(1, "김태희", 90, 90, 90);
		sm.addItem(std1);

		Student std2 = new Student(2, "제시카", 89, 79, 77);
		sm.addItem(std2);

		Student std3 = new Student(3, "김주하", 80, 70, 80);
		sm.addItem(std3);

		Student std4 = new Student(4, "이민정", 78, 77, 77);
		sm.addItem(std4);
		// 삭제
		// sm.delItem(std1);

		// 검색
		Student searchItem = new Student(1, "김태희");
		String result = sm.searchItem(searchItem) ? "존재" : "없음";
		System.out.println(searchItem.getStdNum() + ":"
				+ searchItem.getStdName());

		// 수정
		Student updateItem = new Student(1, "김태희", 91, 93, 94);
		sm.updateItem(updateItem);
		// 출력

		sm.prnItems();
		System.out.println("총점순 정렬(내림차순)");
		sm.prnItems(new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {

				return (int) (o2.getTotal() - o2.getTotal());
			}
		});

		System.out.println("이름순 정렬(오름차순)");
		Comparator<Student> com = new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {

				return o1.getStdName().hashCode() - o2.getStdName().hashCode();
			}

		};
		sm.prnItems(com);

		System.out.println("국어점수정렬(내림차순)");
		sm.prnItems(new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {

				return o2.getKor() - o1.getKor();
			}
		});
		System.out.println("영어점수정렬(내림차순)");
		sm.prnItems(new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {

				return o2.getEng() - o1.getEng();
			}

		});
		System.out.println("수학점수정렬(내림차순)");
		sm.prnItems(new Comparator<Student>() {

			@Override
			public int compare(Student o1, Student o2) {

				return o2.getMath() - o1.getMath();
			}
		});
		for (Student std : stdList) {
			System.out.println(std);

		}


		Collections.shuffle(stdList);
		System.out.println("반복자==============================");
		Student std = null;
		Iterator<Student> iterator = stdList.iterator();
		while (iterator.hasNext()) {
			std = iterator.next();
			System.out.println(std);
		}

	}
}
*/